Release 10.1A: OpenEdge Data Management:
DataServer for Microsoft SQL Server
Retrieving result sets using proc-text-buffer
The
proc–text–buffertechnique offers one approach to access results returned from a data source. The following information is the partial syntax for theDEFINEBUFFERstatement that you use to create a buffer with the same characteristics of theproc–text–buffer:
For a complete description, see the reference entry that discusses the DEFINE BUFFER statement in OpenEdge Development: Progress 4GL Reference .
Technique to use proc-text-buffer
The 4GL procedure in Example 3–6 shows the results of the first stored procedure, pcust, which is Example 3–3 as presented earlier in this section.
Example 3–6: pcust stored procedureThe Progress-defined buffer,
proc–text–buffer, has one character field named proc–text. The buffer accepts the returned database results, converts them toCHARACTERdata type, and concatenates them into one string.The next example, Example 3–7, illustrates returning database results into the
proc–text-bufferand converting the results to theINTEGERdata type.
Example 3–7: Returning database results into the proc-text-buffer and results conversionThe DataServer passes the SQL statement directly to the MSS data source. The Progress Compiler does not process it, so errors occur only at run time and not when you compile a procedure.
Note: The 4GLQUOTERfunction can be useful for quoting values or handling embedded quotes when building SQL statements that will be passed into stored procedures with thesend-sql-statementoption. For more information on theQUOTERfunction, see OpenEdge Development: Progress 4GL Handbook .Assessing result sets obtained from the proc-text-buffer technique
The advantage of using the
proc–text–bufferis that you do not have to worry about what kind of data the procedure returns. The buffer accepts any type of data, in any order, and converts it to the character equivalent. Another benefit of theproc–text–bufferis that it can be used to hold the results from all of the SQL statements included in a stored procedure. However, a buffer that you create can hold the results of only one results set record form one result set at a time.However, a disadvantage in using the
proc-text-buffertechnique is that it is much more difficult to manipulate the data after you receive it as it requires parsing the data. To act on anything butCHARACTERdata, you must extract the data from the buffer and convert it to its original data type before you can use it.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |